package s1.s1_4.crypt1;

import java.io.*;
import java.util.StringTokenizer;

/*
ID: huangmingbo
LANG: JAVA
TASK: crypt1
 */
public class crypt1 {
    public static void main(String[] args) throws IOException {
        try (
                BufferedReader reader = new BufferedReader(new InputStreamReader(crypt1.class.getResourceAsStream(crypt1.class.getSimpleName() + ".in")));
                PrintWriter writer = new PrintWriter(new FileWriter(crypt1.class.getSimpleName() + ".out"));

        ) {

            int N = Integer.parseInt(reader.readLine());
            int[] nums = new int[10];
            StringTokenizer tokenizer = new StringTokenizer(reader.readLine());
            for (int i = 0; i < N; i++) {
                nums[Integer.parseInt(tokenizer.nextToken())] = 1;
            }

            writer.println(getTotal(nums, 10));

        }
    }

    private static int getTotal(int[] nums, int N) {

        int a, b, c, d, e;
        int total = 0;

        for (a = 1; a < N; a++) {

            if (nums[a] < 1) {
                continue;
            }

            for (b = 1; b < N; b++) {
                if (nums[b] < 1) {
                    continue;
                }

                for (c = 1; c < N; c++) {
                    if (nums[c] < 1) {
                        continue;
                    }


                    for (d = 1; d < N && nums[a] * nums[d] < 10; d++) {

                        if (nums[d] < 1) {
                            continue;
                        }


                        for (e = 1; e < N && nums[a] * nums[e] < 10; e++) {

                            if (nums[e] < 1) {
                                continue;
                            }

                            if (check(a, b, c, d, e, nums)) {
                                total++;
                            }
                        }
                    }
                }
            }
        }
        return total;
    }

    private static boolean check(int a, int b, int c, int d, int e, int[] nums) {

        int tmp = 100 * a + 10 * b + c;
        int tmp2 = e * tmp;
        int tmp3 = d * tmp;
        int tmp4 = tmp2 + tmp3 * 10;

        if (tmp2 >= 1000 || tmp3 >= 1000 || tmp4 >= 10000) {
            return false;
        }

        while (tmp2 > 0) {
            if (nums[tmp2 % 10] == 0) {
                return false;
            }
            tmp2 /= 10;
        }

        while (tmp3 > 0) {
            if (nums[tmp3 % 10] == 0) {
                return false;
            }
            tmp3 /= 10;
        }

        while (tmp4 > 0) {
            if (nums[tmp4 % 10] == 0) {
                return false;
            }
            tmp4 /= 10;
        }


        return true;
    }
}
